//
//  VCOfxiangce.m
//  project-A (pianke)
//
//  Created by dllo on 16/3/1.
//  Copyright © 2016年 scott. All rights reserved.
//

#import "VCOfxiangce.h"

@interface VCOfxiangce ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate>

@property (nonatomic,retain)UIImageView *headImageView;
@end

@implementation VCOfxiangce

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.headImageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
    _headImageView.backgroundColor = [UIColor yellowColor];
    _headImageView.layer.cornerRadius = 50;
    _headImageView.layer.masksToBounds = YES;
    _headImageView.tag = 101;
    [self.view addSubview:_headImageView];
    
    _headImageView.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
    [_headImageView addGestureRecognizer:tap];
}

-(void)dealloc{
    
    [_headImageView release];
    [super dealloc];
}

- (void)tapAction:(UIImageView*)sender
{
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc]init];
    imagePicker.allowsEditing = YES;
    imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    imagePicker.delegate = self;
    [self presentViewController:imagePicker animated:YES completion:^{
        NSLog(@"打开相册");
    }];
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [picker dismissViewControllerAnimated:YES completion:^{
        NSLog(@"取消");
    }];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    _headImageView.image = info[UIImagePickerControllerEditedImage];
    NSLog(@"%@",info);
    [picker dismissViewControllerAnimated:YES completion:^{
        NSLog(@"选照片");
    }];
    
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
